﻿using System;
using Autodesk.Revit.DB;
using ModelCheckUtility.ControlLayer;
using ModelCheckUtility.Properties;

namespace ModelCheckUtility.ModelLayer
{
	public class BaseElementPacker : IResultPackerTag
	{
		public int ThisElementPackerId
		{
			get
			{
				return this.m_nthisElementPackerId;
			}
		}

		public Element ThisElement
		{
			get
			{
				return this.m_thisElement;
			}
		}

		public RevitLinkInstance UseRevitLinkInstance
		{
			get
			{
				return this.m_useRevitLinkInstance;
			}
		}

		public Transform UseTransform
		{
			get
			{
				return this.m_useTransform;
			}
		}

		public bool IfLinkedFileElement
		{
			get
			{
				return this.m_bifLinkedFileElement;
			}
		}

		public int ElementId
		{
			get
			{
				return this.m_nelementId;
			}
		}

		public int LinkInstanceId
		{
			get
			{
				return this.m_nlinkInstanceId;
			}
		}

		public BaseElementPacker(Element inputElement, RevitLinkInstance useRevitLinkInstance = null, object[] otherValues = null)
		{
			this.m_thisElement = inputElement;
			if (inputElement != null)
			{
				this.m_nelementId = this.m_thisElement.Id.IntegerValue;
			}
			else
			{
				this.m_nelementId = int.Parse(Resources.Str_ValueOfNoneElementId);
			}
			if (useRevitLinkInstance != null)
			{
				this.m_useRevitLinkInstance = useRevitLinkInstance;
				this.m_useTransform = this.m_useRevitLinkInstance.GetTotalTransform();
				this.m_bifLinkedFileElement = true;
				this.m_nlinkInstanceId = this.m_useRevitLinkInstance.Id.IntegerValue;
			}
			else
			{
				this.m_useRevitLinkInstance = null;
				this.m_useTransform = null;
				this.m_bifLinkedFileElement = false;
				this.m_nlinkInstanceId = int.Parse(Resources.Str_ValueOfNoneElementId);
			}
			this.m_nthisElementPackerId = ElementPackerManger.AddElementPacker(this);
		}

		public bool TryDeletElementPacker()
		{
			return ElementPackerManger.TryDeleteElementPacker(this.m_nthisElementPackerId);
		}

		public override bool Equals(object obj)
		{
			if (!(obj is BaseElementPacker))
			{
				return false;
			}
			if (obj == null)
			{
				return base.Equals(obj);
			}
			return (obj as BaseElementPacker).ElementId == this.ElementId && (obj as BaseElementPacker).LinkInstanceId == this.m_nlinkInstanceId;
		}

		public override int GetHashCode()
		{
			return base.GetHashCode();
		}

		private int m_nthisElementPackerId;

		private Element m_thisElement;

		private RevitLinkInstance m_useRevitLinkInstance;

		private Transform m_useTransform;

		private bool m_bifLinkedFileElement;

		private int m_nelementId;

		private int m_nlinkInstanceId;
	}
}
